//Fri Jun  3 08:40:30 CDT 2011
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>

using namespace std;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

class grafixMask {
public:
	vector <int> sortedAreas(vector <string>);
	void init(vector<string>);
	int dfs(int, int);
	bool avaiID[400][600];
};

void grafixMask::init(vector<string> rec){
	memset(avaiID, false, sizeof(avaiID));
	int M = rec.size();
	for(int i=0; i<M; i++){
		stringstream s(rec[i]);
		int x1, y1, x2, y2;
		s >> x1 >> y1 >> x2 >> y2;
//		cout << x1 << "," << y1 << "," << x2 << "," << y2 << endl;
		for(int x=x1; x<=x2; x++){
			for(int y=y1; y<=y2; y++){
				avaiID[x][y] = true;
			}
		}
	}
}

int grafixMask::dfs(int x, int y){
	if(avaiID[x][y])
		return 0;
	avaiID[x][y] = true;
	int count = 1;
	for(int i=0; i<4; i++){
		int xx = x + dx[i];
		int yy = y + dy[i];
		if(xx <0 || xx >= 400 || yy < 0 || yy >= 600) continue;
		count += dfs(xx, yy);
	}
	return count;
}

vector <int> grafixMask::sortedAreas(vector <string> rectangles) {
	init(rectangles);
	vector<int> res;
	for(int i=0; i<400; i++){
		for(int j=0; j<600; j++){
			if(avaiID[i][j] == false){
				int count = dfs(i, j);
				res.push_back(count);
			}
		}
	}
	sort(res.begin(), res.end());
	return res;
}

//Powered by [KawigiEdit] 2.0!;
